package org.budo.netty.servlet.server.session.repository;

import javax.servlet.http.HttpSession;

/**
 * @author li
 */
public class SessionRepositoryWrapper implements SessionRepository {
    private SessionRepository sessionRepository;

    public SessionRepositoryWrapper(SessionRepository sessionRepository) {
        this.sessionRepository = sessionRepository;
    }

    @Override
    public String createSessionId() {
        return this.sessionRepository.createSessionId();
    }

    @Override
    public void saveSession(HttpSession session) {
        String id = session.getId();
        if (null == id) {
            return;
        }

        this.sessionRepository.saveSession(session);
    }

    @Override
    public HttpSession findById(String id) {
        if (null == id) {
            return null;
        }

        return this.sessionRepository.findById(id);
    }

    @Override
    public void deleteById(String id) {
        if (null == id) {
            return;
        }

        this.sessionRepository.deleteById(id);
    }
}